// pages/bookseats/bookseats.js

const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    selectNum:0,
    person_num:'',
    selectDay:0,
    day:'',
    selectTime:0,
    time:'',
    selectSeat:0,
    seat:'',
    list_p:[{
      id:1,
      num:"1人"
    },{
      id: 2,
      num: "2人"
    },{
      id: 3,
      num: "3人"
    },{
      id: 4,
      num: "4人"
    },{
      id: 5,
      num: "5人"
    }],
    list_d:[],
    list_t:[{
      id:1,
      time:"11:30"
    },{
      id: 2,
      time: "12:00"
    },{
      id:3,
      time:'12:30'
    },{
      id:4,
      time:'13:00'
    },{
      id:5,
      time:'13:30'
    }],
    list_s:[{
      id:1,
      seat:'位置不限'
    },{
      id:2,
      seat:'尽量包间'
    },{
      id:3,
      seat:'必须包间'
    }]

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    var dateAry=[];
    
    for(var i=0;i<5;i++){
      console.log(app.util.getDateStr(i));
      var obj = {};
      obj.id = i+1;
      obj.date = app.util.getDateStr(i);

      dateAry.push(obj) 
    }
    this.setData({
      list_d: dateAry,
      day: app.util.getNowTime(),
      time: this.data.list_t[0].time,
      person_num: this.data.list_p[0].num,
      seat: this.data.list_s[0].seat
    })


  },
  positionNumTap:function(e){
    console.log(e.currentTarget.dataset.index);
    var index = e.currentTarget.dataset.index;
    var num = e.currentTarget.dataset.num;
    this.setData({
      selectNum: index,
      person_num:num
    })
  },
  positionDayTap:function(e){
    console.log(e.currentTarget.dataset.index);
    var index = e.currentTarget.dataset.index;
    var date = e.currentTarget.dataset.date;
    this.setData({
      selectDay: index,
      day:date
    })
  },
  positionTimeTap:function(e){
    var index = e.currentTarget.dataset.index;
    var time = e.currentTarget.dataset.time;
    this.setData({
      selectTime: index,
      time: time

    })
  },
  positionSeatTap:function(e){
    var index = e.currentTarget.dataset.index;
    var seat = e.currentTarget.dataset.seat;
    this.setData({
      selectSeat: index,
      seat:seat
    })
  },
  yuding:function(){
    console.log("确定订座");
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})